package com.dream.cms;

import com.dream.cms.config.KafkaTopicProperties;
import com.dream.cms.entity.Log;
import com.dream.cms.service.LogKafkaConsumer;
import com.dream.cms.service.Sender;
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.kafka.core.*;
import org.springframework.kafka.support.serializer.JsonSerializer;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

@SpringBootApplication
public class CmsApplication {



//    @Value("${tpd.topic-name}")
//    private String topicName;
//    @Autowired
//    private KafkaTemplate<String, Object> kafkaTemplate;

    public static void main(String[] args) throws ExecutionException, InterruptedException {
//        ConfigurableApplicationContext context = SpringApplication.run(CmsApplication.class, args);

        SpringApplication.run(CmsApplication.class, args);
//        LogKafkaConsumer service = context.getBean(LogKafkaConsumer.class);
//        System.out.println("执行到了");
//        service.add(new Log());
//        UserRepository userRepository = context.getBean(UserRepository.class);
//        List<User> result = userRepository.findAll();
//        if(!CollectionUtils.isEmpty(result)){
//            for(int i =0,len = result.size();i<len;i++){
//                System.out.println("wgq:"+result.get(i).getUserName());
//            }
//        }
//        Sender sender = context.getBean(Sender.class);
//        sender.sendMessage("aaa");
//        for (int i = 0; i < 3; i++) {
//            //调用消息发送类中的消息发送方法
//            sender.sendTest(i + "");
//            try {
//                Thread.sleep(3000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }

//        SpringApplication.run(CmsApplication.class, args);
    }



}
